package com.example.test_mqtt2

import android.os.Bundle
import android.view.View
import android.widget.EditText
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

class MainActivity : AppCompatActivity() {
    private lateinit var mqttManager: MqttManager
    private lateinit var editText: EditText
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)
        editText = findViewById(R.id.et)
        mqttManager = MqttManager(this,"tcp://10.161.9.80:1883")
        mqttManager.connect()
    }

    fun send(view: View) {
        mqttManager.publish("test/android",editText.text.toString())
    }

    override fun onDestroy() {
        super.onDestroy()
        mqttManager.disconnect()
    }
}